package com.yc.utils;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.prefs.Preferences;


public class RegisterUtil {

	public void addRegister(Map<String, String> map) {
		try {
			Preferences pre = Preferences.userNodeForPackage(RegisterUtil.class);
			// 信息判空 
			if(null != map && !map.isEmpty()) {
				// 获取所有的键值
				Set<String> keySet = map.keySet();
				// 将键视图进行迭代
				Iterator<String> iterator = keySet.iterator();
				// 循环
				while(iterator.hasNext()) {
					String key = iterator.next();
					String value = map.get(key);
					// 数据注册到注册表来
					pre.put(key, value);
				}
			}
			pre.flush();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/**
	 * 
	 * @param key
	 */
	public void delteInfo(String key) {
		Preferences pre = Preferences.userNodeForPackage(RegisterUtil.class);
		pre.remove(key);
	}
	
	
	public String findInfo(String key) {
		Preferences pre = Preferences.userNodeForPackage(RegisterUtil.class);
		return pre.get(key, null);
	}
	
	
}
